﻿using DAEProde.Domain;
using DAEProde.Tasks.ViewModels;
using SharpLite.Domain.DataInterfaces;
using System.Linq;
using System.Collections.Generic;

namespace DAEProde.Tasks
{
    public class ResultCudTasks : BaseEntityCudTasks<Tournament, ResultsViewModel>
    {
        public ResultCudTasks(IRepository<Tournament> userRepository, IRepository<MatchDate> matchDateRepository, IRepository<Team> teamRepository)
            : base(userRepository) { }

        protected override void TransferFormValuesTo(Tournament toUpdate, Tournament fromForm)
        {
            toUpdate.Name = fromForm.Name;
        }

        // Construccion basica del view model que inicializa lista de equipos para el dropdown
        public ResultsViewModel CreateEditViewModel(Tournament t, MatchDate m, IEnumerable<EditUserViewModel> s)
        {
            var viewModel = base.CreateEditViewModel();
                        
            viewModel.Tournament = t;

            viewModel.MatchDate = m;

            viewModel.Scores = s;

            return viewModel;
        }
    }
}